//index.js
const app = getApp()
const { envList } = require('../../envList.js')

Page({
  data: {
    isPositionPermited: true,
    pics: ["a", "b"],
    seatings: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
       1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 
       1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 
    ],
    left_seatings: [ 1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 1, 1,
       1, 1, 2, 1,
    ],
    right_seatings: [1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 2, 1, 
      1, 1, 1, 1, 
      1, 1, 1, 1, 
      1, 1, 2, 1, 
      1, 1, 1, 1, 
    ],
    hallNumber: "九",
    menus: [
    ],
    showUploadTip: false,
    envList,
    selectedEnv: envList[0],
    haveCreateCollection: false
  },
  onShow() {
    this.popup = this.selectComponent('#popup');
    // console.log(this.popup);
  },
  showPopup() {
    this.popup.showPopup();
  },
  _error(e) {
    console.log('子组件点击了error', e);
  },
  onChangeShowEnvChoose() {
    wx.showActionSheet({
      itemList: this.data.envList.map(i => i.alias),
      success: (res) => {
        this.onChangeSelectedEnv(res.tapIndex)
      },
      fail(res) {
        console.log(res.errMsg)
      }
    })
  },

  onChangeSelectedEnv(index) {
    if (this.data.selectedEnv.envId === this.data.envList[index].envId) {
      return
    }
  },

  jumpPage(e) {
    wx.navigateTo({
      url: `/pages/${e.currentTarget.dataset.page}/index?envId=${this.data.selectedEnv.envId}`,
    })
  },
})
